import UnityEngine
		
class TP_Motor(MonoBehaviour):
	public static instance as TP_Motor
	public moveSpeed as single = 10
	public moveVector as Vector3
	
	def Awake ():
		instance = self
	
	# Update is called once per frame
	public def UpdateMotor ():
		SnapAlignCharacterWithCamera()
		ProcessMotion()
		
	def ProcessMotion():
		moveVector = transform.TransformDirection(moveVector)
		
		if(moveVector.magnitude>1):
			moveVector = Vector3.Normalize(moveVector)
			
		moveVector *= moveSpeed
		
		moveVector *= Time.deltaTime
		
		TP_Controller.characterController.Move(moveVector)
		
	def SnapAlignCharacterWithCamera():
		if (moveVector.x !=0 or moveVector.z !=0):
			transform.rotation=Quaternion.Euler(transform.eulerAngles.x, \
			Camera.mainCamera.transform.eulerAngles.x, \
			transform.eulerAngles.z)
